//
//  AvtiTableViewCell.m
//  电影er
//
//  Created by dllo on 16/6/23.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "AvtiTableViewCell.h"
#import "AvtivityModel.h"
#import "Hight.h"
#define kWidth self.contentView.frame.size.width
#define kHeight self.contentView.frame.size.height
@interface AvtiTableViewCell()
@property (nonatomic,retain)UILabel *titlelabel;
@property(nonatomic,retain)UILabel *timelabel;
@property(nonatomic,retain)UILabel *timelabele;
@property(nonatomic,retain)UILabel *placelabel;
@property(nonatomic,retain)UILabel *classlabel;
@property(nonatomic,retain)UILabel *wisherlabel;
@property(nonatomic,retain)UILabel *particlabel;
@property(nonatomic,retain)UIImageView *image;
@property (nonatomic,retain)UIImageView *imagebeijing;
@property (nonatomic,retain)UIImageView *imageditu;
@property (nonatomic,retain)UIImageView  *image1;
@property (nonatomic,retain)UIImageView *image2;
@property (nonatomic,retain)UIImageView *image3;
@property(nonatomic,retain)UILabel *label1;
@property(nonatomic,retain)UILabel *label2;
@property (nonatomic,retain)UILabel *label3;


@end
@implementation AvtiTableViewCell
-(void)dealloc{
    [_timelabel release];
    [_titlelabel release];
    [_timelabele release];
    [_placelabel release];
    [_classlabel release];
    [_wisherlabel release];
    [_particlabel release];
    [_image release];
    [_imagebeijing release];
    [_imageditu release];
    
    
    [_image1 release];
    [_image2 release];
    [_image3 release];
    [super dealloc];
    
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        
        
        self.imagebeijing = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"bg_eventlistcell@2x.png"]];
        [self.contentView addSubview:_imagebeijing];
        [_imagebeijing release];
        
        
        self.titlelabel = [[UILabel alloc]init];
        [self.imagebeijing addSubview: _titlelabel];
        [_titlelabel release];
        
        self.imageditu = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"bg_share_large.png"]];
        [self.imagebeijing addSubview:_imageditu];
        [_imagebeijing release];
        
        self.timelabel =[[UILabel alloc]init];
       [self.imageditu addSubview:_timelabel];
        [_timelabel release];
        
        self.timelabele =[[UILabel alloc]init];
        [self.imageditu addSubview:_timelabele];
        [_timelabele release];
        
        
        UIImage *image1 = [UIImage imageNamed:@"icon_date_blue.png"];
        self.image1 =[[UIImageView alloc]initWithImage:image1];
        [self.imageditu addSubview: _image1];
        [_image1 release];
        UIImage *image2 = [UIImage imageNamed:@"icon_spot_blue@2x.png"];
        self.image2 =[[UIImageView alloc]initWithImage:image2];
        [self.imageditu addSubview: _image2];
        [_image2 release];
      UIImage *image3=[UIImage imageNamed:@"icon_catalog_blue.png"];
        self.image3 =[[UIImageView alloc]initWithImage:image3];
        [self.imageditu addSubview: _image3];
        [_image3 release];
        
        
        self.label1 = [[UILabel alloc]init];
        self.label1.text = @"类型:";
        [self.imageditu addSubview:_label1];
        [_label1 release];
        
        self.label2 = [[UILabel alloc]init];
        self.label2.text = @"感兴趣:";
        [self.imageditu addSubview:_label2];
        [_label2 release];
        self.label3 = [[UILabel alloc]init];
        self.label3.text = @"参加:";
        [self.imageditu addSubview:_label3];
        [_label3 release];
        
        self.placelabel = [[UILabel alloc]init];
        [self.imageditu addSubview:_placelabel];
        [_placelabel release];

        self.classlabel =[[UILabel alloc]init];
        [self.imageditu addSubview:_classlabel];
        [_classlabel release];

        self.wisherlabel = [[UILabel alloc]init];
        self.wisherlabel.textColor = [UIColor redColor];
        [self.imageditu addSubview:_wisherlabel];
        [_wisherlabel release];
        self.particlabel = [[UILabel alloc]init];
        self.particlabel.textColor = [UIColor redColor];
        [self.imageditu addSubview:_particlabel];
        [_particlabel release];
        
        
        self.image = [[UIImageView alloc]init];
        [self.imageditu addSubview:_image];
        [_image release];
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    

    self.imagebeijing.frame = CGRectMake(10, 0, self.contentView.bounds.size.width-20,220);
    self.imageditu .frame = CGRectMake(5, 40, self.imagebeijing.bounds.size.width-10, self.imagebeijing.bounds.size.height-50);
    self.titlelabel.frame = CGRectMake(10, 5, self.imagebeijing.bounds.size.width-20, 30);
    self.placelabel.frame = CGRectMake(40, 50, 250, 30);
    self.placelabel.numberOfLines = 1;
    self.classlabel.frame = CGRectMake(90, 90, 50, 30);
    self.placelabel.numberOfLines = 1;
    self.wisherlabel.frame = CGRectMake(100, 135, 100, 30);
    self.particlabel.frame = CGRectMake(230, 135, 100, 30);
    self.timelabel.frame = CGRectMake(40, 0, 200, 30);
     self.timelabele.frame = CGRectMake(40, 20, 200, 30);
    
    
    
    
    self.image1.frame = CGRectMake(15, 10 , 30, 30);
    self.image2.frame = CGRectMake(15,50, 30, 30);
    self.image3.frame = CGRectMake(15, 90 , 30, 30);
    self.label1.frame = CGRectMake(45, 90 , 100, 30);
    self.label2.frame = CGRectMake(45, 135 , 100, 30);
    self.label3.frame = CGRectMake(180, 135 , 100, 30);

    
    
}




-(void)setModel:(AvtivityModel *)model{
    if(_model != model){
                [_model release];
                _model = [model retain];
            }
            _titlelabel.text = model.title;
    _timelabel.text = model.begin_time;
    _titlelabel.font = [UIFont boldSystemFontOfSize:20];
    _timelabele.text = model.end_time;
    _placelabel.text = model.address;
    _classlabel.text =model.category_name;
    _wisherlabel.text = [NSString stringWithFormat:@"%ld",model.wisher_count];
    _particlabel.text = [NSString stringWithFormat:@"%@",model.participant_count];
    

    self.image.frame = CGRectMake(280, 5, 100, 160);
    NSURL *url = [NSURL URLWithString:model.image];
    NSData *data= [NSData dataWithContentsOfURL:url];
    
    
    _image.image = [UIImage imageWithData:data];
    
    
}





@end
